package com.econ.powercloud.ems.timing.report.strategy;

import com.econ.powercloud.clickhouse.entity.EmsStatisticalMonth;
import com.econ.powercloud.ems.dal.entity.EmsDevice;
import com.econ.powercloud.ems.pojo.EmsPriceInfoVO;
import com.econ.powercloud.ems.pojo.InComeCalculationVO;
import com.econ.powercloud.ems.pojo.MeterHisDataVO;

import java.util.Map;

/**
 * @Author : zjf
 * @Description : 计算某个电表设备尖峰平谷收益抽象类
 * @Date : 2022/3/26 10:59
 * @Modified by : zjf
 * 继承该抽象类的实现类,需要在无参函数中,对calModelPid进行设置值
 */
public abstract class AbstractIncomeCalculationProcess {

    /**
     * 尖峰平谷策略(见IncomeCalculationType策略)
     */
    private Integer incomeModelId;

    /**
     * 处理数据，如计算本期示数,上期示数,电量,计费电价,金额等
     * @param meterHisDataVO : 0点时尖峰平谷的断面数据
     * @param timeEpMap : 某电表在EmsStatisticalMonth表中昨日的尖峰平谷电量,key:columnId
     * @param emsDevice : 需要计算的电表设备
     * @param emsPriceInfoVO : 该电表设备使用的电价模型的电价VO类
     * @param startDayTime : 时间戳
     * @return
     */
    public abstract InComeCalculationVO calculation(MeterHisDataVO meterHisDataVO,
                                                    Map<String, EmsStatisticalMonth> timeEpMap,
                                                    EmsDevice emsDevice, EmsPriceInfoVO emsPriceInfoVO,
                                                    Long startDayTime);


    public Integer getIncomeModelId() {
        return incomeModelId;
    }

    public void setIncomeModelId(Integer incomeModelId) {
        this.incomeModelId = incomeModelId;
    }

    public Double getPrice(String columnId, EmsPriceInfoVO emsPriceInfoVO) {
        if(emsPriceInfoVO == null){
            return null;
        }
        switch (columnId){
            case "Eppt":
                return null;
            case "Epp1":
                return emsPriceInfoVO.getSpikePrice();
            case "Epp2":
                return emsPriceInfoVO.getPeakPrice();
            case "Epp3":
                return emsPriceInfoVO.getFlatPrice();
            case "Epp4":
                return emsPriceInfoVO.getValleyPrice();
            case "Enpt":
                return null;
            case "Enp1":
                return emsPriceInfoVO.getSpikePrice();
            case "Enp2":
                return emsPriceInfoVO.getPeakPrice();
            case "Enp3":
                return emsPriceInfoVO.getFlatPrice();
            case "Enp4":
                return emsPriceInfoVO.getValleyPrice();
            default:
                return null;
        }
    }
}
